Fix pydantic validation errors bypassing interceptor layer #1125
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fix pydantic validation errors bypassing interceptor layer
Summary
This PR fixes an issue where pydantic validation errors during argument decoding were bypassing the interceptor layer because they occurred in the data converter and were not properly caught by the existing error handling.
The core change modifies
CompositePayloadConverter.from_payloadsmethod to catch pydanticValidationErrorexceptions and wrap them asRuntimeError, ensuring they follow the same error handling path as other conversion errors. This allows them to be properly caught by the existingworkflow_is_failure_exceptionlogic and configured as workflow failures when appropriate.Key Changes:
CompositePayloadConverter.from_payloadsto detect and wrap pydantic ValidationErrorReview & Testing Checklist for Human
tests/contrib/pydantic/and related tests still pass to verify no regressions were introduced.{"bar": 123}to an activity expectingFoo(bar: str). Manually verify that pydantic validation errors in activities are now properly handled.Notes
This PR addresses the issue described in the original report where pydantic validation errors were generating "Failed decoding arguments" logs because they bypassed the interceptor layer. The solution is conservative and maintains existing behavior for all non-pydantic exceptions.
Link to Devin run: https://app.devin.ai/sessions/a3666eda1d1a47d0a389cbe3e2843829
Requested by: @deepika-awasthi